package com.view.footballteam;

import com.action.table.JTableMainView;
import com.dao.CoachDao;
import com.dao.FootballTeamDao;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class FootballTeamMain {
    private JFrame jf=null;
    private JButton view=new JButton("浏览"); //浏览所有数据
    private JButton qur=new JButton("查询");   //查询数据
    private JButton update =new JButton("修改"); //修改数据
    private JButton delete=new JButton("删除"); //删除数据
    private JButton insert=new JButton("添加");    //添加数据
    public FootballTeamMain(){
        jf=new JFrame("球队信息操作");
        jf.setLayout(null);
        jf.setSize(390,120);
        //浏览按钮
        view.setSize(60,40);
        view.setLocation(20,30);
        view.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if(e.getSource()==view){
                    JFrame it=new JFrame("正在加载");
                    it.setVisible(true);
                    new JTableMainView("球队信息",new FootballTeamDao().browsingData());
                    it.setVisible(false);
                }
            }
        });
        //查询按钮
        qur.setSize(60,40);
        qur.setLocation(90,30);
        qur.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if(e.getSource()==qur){
                    new FootballTeamQurey();
                }
            }
        });

        //修改
        update.setSize(60,40);
        update.setLocation(160,30);
        update.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if(e.getSource()== update){
                    new FootballTeamUpdate();
                }
            }
        });

        //删除
        delete.setSize(60,40);
        delete.setLocation(230,30);
        delete.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new FootballTeamDelete();
            }
        });

        //添加
        insert.setSize(60,40);
        insert.setLocation(300,30);
        insert.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if(e.getSource()==insert){
                    new FootballTeamInsert();
                }
            }
        });

        jf.add(insert);
        jf.add(update);
        jf.add(delete);
        jf.add(qur);
        jf.add(view);
        jf.setLocation(400,400);
        jf.setVisible(true);
    }
}
